<?php
  session_start();
?>
<html>
<head>
<meta http-equiv="Content-Type" content="html/text; charset=utf-8" />
<title>简易BBS系统</title>
</head>
<body>
<?php
include "head.php";
include "mysql.php";
include "myfunction.php";
$aa=new mysql;
$aa->link("");
$bb=new myfunction;
include "total_info.php";
?>
<table width="98%" border="0" align="center" cellspacing="0"  cellpadding="0">
<tr>
 <td height="25" align="left"><a href="indexs.php">简易BBS系统</a>>>新用户注册</td>
</tr>
<tr>
 <td height="25" align="center" bgcolor="#000000"><font color="#FFFFFF">发布新帖</font></td>
</tr>
</table>

  <?php
  $tijiao=$_POST["tijiao"];
  if($tijiao == "提交"){
    $user_name=$_POST["user_name"];
  	$query="select * from user_info where user_name='$user_name'";
  	$rst=$aa->excu($query);
        
  	if(mysql_num_rows($rst)!=0){
  		echo "<script laguage=javascript>alert('用户名已存在，请重新输入');location.href='register.php';</script>";
  		}else {
  		$user_pw1=$_POST["user_pw1"];
  		$user_pw2=$_POST["user_pw2"];
  		if($user_pw1!=$user_pw2){
  			echo "<script laguage=javascript>alert('两次输入密码不一致，请重新输入');location.href='register.php';</script>";
  		}else{
  			$today=date("Y-m-d H-i-s");
  			$query="insert into user_info (user_name,user_pw,time1) values ('$user_name','$user_pw1','$today')";
  			$rst=$aa->excu($query);
                          
  			echo "<script laguage=javascript>alert('恭喜您注册成功');location.href='indexs.php';</script>";
  			$register_tag=1;
  		}

  	}
  }
  if($register_tag!=1){
  	?>

 <form action="#" method="post">
  <table width="88%" border="1" align="center" cellspacing="1"  cellpadding="0">
 <tr>
  <td height="25" align="right" width="45%">用户名</td>
  <td height="25" align="left" width="55%"><input type="text" name="user_name"></td>
 </tr>
 <tr>
  <td height="25" align="right" width="30%">密码</td>
  <td height="25" align="left" width="70%"><input type="password" name="user_pw1"></td>
 </tr>
 <tr>
  <td height="25" align="right" width="30%">重复密码</td>
  <td height="25" align="left" width="70%"><input type="password" name="user_pw2"></td>
 </tr>
 <tr>
  <td height="25" align="center" colspan="2">
  <input type="submit" name="tijiao"  value="提交"/>&nbsp;&nbsp;
  <input type="reset"  value="重置"/>
 </tr>
</table>
</form>
<?php } ?>
<?php include "foot.php" ?>
</body>
</html>



